<script type="text/javascript">
var gridimgpath = "<?php echo $theme; ?>"

$("#<?php echo $table ?>").jqGrid({        
   	url: '<?php echo $url ?>',
	datatype: "json",
	height: "<?php echo $height ?>",
   	colNames:[<?php echo $labels ?>],
   	colModel:[
   	<?php foreach($columns as $key => $column): ?>
   	 { <?php echo $column ?> },   		
    <?php endforeach ?>
   	],
   	rowNum:      <?php echo $row_num ?>,
   	imgpath:     gridimgpath,
   	mtype:       "POST",
   	pager:       $('#pager_<?php echo $table ?>'),
   	pgbuttons:   false,
   	pgtext:      false,
   	pginput:     false,
   	sortname:    "<?php echo $sort_name ?>",
    viewrecords: true,
    <?php if(isset($edit_url)): ?>
    editurl:     "<?php echo $edit_url ?>",
    <?php endif; ?>
    sortorder:   "<?php echo $sort_order ?>" 
});

var timeoutHnd;
var flAuto = false;

function doSearch<?php echo $table ?>(ev)
{
  if(!flAuto)
    return;
  if(timeoutHnd)
    clearTimeout(timeoutHnd)
  timeoutHnd = setTimeout(gridReload<?php echo $table ?>, 500)
}

function gridReload<?php echo $table ?>()
{
  var nombre = $("#nombre<?php echo $table ?>").val();
  var codigo = $("#codigo<?php echo $table ?>").val();
  $("#<?php echo $table ?>").setGridParam({ url: '<? echo $url ?>?nombre=' + nombre + '&codigo=' + codigo, page:1}).trigger("reloadGrid");
}

function enableAutosubmit<?php echo $table ?>(state)
{
  flAuto = state;
  $("#submitButton<?php echo $table ?>").attr("disabled",state);
}
 
</script>